/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.swt.mto.thithu.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import com.swt.mto.thithu.service.LoadAjaxLocalServiceUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.HashMap;
import java.util.Map;

/**
 * @author tuan.nguyen
 */
public class LoadAjaxClp extends BaseModelImpl<LoadAjax> implements LoadAjax {
	public LoadAjaxClp() {
	}

	public Class<?> getModelClass() {
		return LoadAjax.class;
	}

	public String getModelClassName() {
		return LoadAjax.class.getName();
	}

	public long getPrimaryKey() {
		return _loadAjaxId;
	}

	public void setPrimaryKey(long primaryKey) {
		setLoadAjaxId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_loadAjaxId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("loadAjaxId", getLoadAjaxId());
		attributes.put("loadWeb", getLoadWeb());
		attributes.put("ajax", getAjax());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long loadAjaxId = (Long)attributes.get("loadAjaxId");

		if (loadAjaxId != null) {
			setLoadAjaxId(loadAjaxId);
		}

		String loadWeb = (String)attributes.get("loadWeb");

		if (loadWeb != null) {
			setLoadWeb(loadWeb);
		}

		String ajax = (String)attributes.get("ajax");

		if (ajax != null) {
			setAjax(ajax);
		}
	}

	public long getLoadAjaxId() {
		return _loadAjaxId;
	}

	public void setLoadAjaxId(long loadAjaxId) {
		_loadAjaxId = loadAjaxId;
	}

	public String getLoadWeb() {
		return _loadWeb;
	}

	public void setLoadWeb(String loadWeb) {
		_loadWeb = loadWeb;
	}

	public String getAjax() {
		return _ajax;
	}

	public void setAjax(String ajax) {
		_ajax = ajax;
	}

	public BaseModel<?> getLoadAjaxRemoteModel() {
		return _loadAjaxRemoteModel;
	}

	public void setLoadAjaxRemoteModel(BaseModel<?> loadAjaxRemoteModel) {
		_loadAjaxRemoteModel = loadAjaxRemoteModel;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			LoadAjaxLocalServiceUtil.addLoadAjax(this);
		}
		else {
			LoadAjaxLocalServiceUtil.updateLoadAjax(this);
		}
	}

	@Override
	public LoadAjax toEscapedModel() {
		return (LoadAjax)Proxy.newProxyInstance(LoadAjax.class.getClassLoader(),
			new Class[] { LoadAjax.class }, new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		LoadAjaxClp clone = new LoadAjaxClp();

		clone.setLoadAjaxId(getLoadAjaxId());
		clone.setLoadWeb(getLoadWeb());
		clone.setAjax(getAjax());

		return clone;
	}

	public int compareTo(LoadAjax loadAjax) {
		long primaryKey = loadAjax.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		LoadAjaxClp loadAjax = null;

		try {
			loadAjax = (LoadAjaxClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = loadAjax.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(7);

		sb.append("{loadAjaxId=");
		sb.append(getLoadAjaxId());
		sb.append(", loadWeb=");
		sb.append(getLoadWeb());
		sb.append(", ajax=");
		sb.append(getAjax());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(13);

		sb.append("<model><model-name>");
		sb.append("com.swt.mto.thithu.model.LoadAjax");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>loadAjaxId</column-name><column-value><![CDATA[");
		sb.append(getLoadAjaxId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>loadWeb</column-name><column-value><![CDATA[");
		sb.append(getLoadWeb());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>ajax</column-name><column-value><![CDATA[");
		sb.append(getAjax());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _loadAjaxId;
	private String _loadWeb;
	private String _ajax;
	private BaseModel<?> _loadAjaxRemoteModel;
}